export class WorkerProxy {
    constructor(job) {
        this.worker = new Worker(job);
        this.worker.onmessage = (e) => {
            if (this.event_ && typeof this.event_ === "function") {                
                this.event_(e);
            }
        }
        this.event_ = null;
    }
    
    set onmessage(value) {
        if (typeof value === "function") {
            this.event_ = value;
        }
    }
    
    postMessage(data) {
        //console.log(data);
        return this.worker.postMessage(data);
    }
}